function instanceOf (obj, constructor) {
  // 1.分别获取二者的原型
  let __proto__ = Object.getPrototypeOf(obj)
  let prototype = constructor.prototype
  // 2.无限循环沿着原型链一层一层往上查询
  while (true) {
    if (!__proto__) return false
    if (__proto__ === prototype) return true
    __proto__ = Object.getPrototypeOf(__proto__)
  }
}

console.log(instanceOf([], Object))
